package com.huawei.appmarket.service.store.awk.card;

import android.app.Activity;
import android.content.Context;
import android.text.SpannableString;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.huawei.appgallery.foundation.card.base.card.BaseDistCard;
import com.huawei.appgallery.foundation.ui.framework.cardkit.bean.CardBean;
import com.huawei.appgallery.productpurchase.api.ProductDetailBean;
import huawei.widget.HwButton;
import huawei.widget.HwTextView;
import o.azb;
import o.cgz;
import o.chm;
import o.chy;
import o.cks;
import o.cku;
import o.crj;
import o.Logger;
import o.dof;
import o.ContentManager;
import o.eec;
import o.eed;
import o.ehw;
import o.eqx;
import o.evx;
import o.ewm.j;
import o.ewm.n;

public class ProductListCard extends BaseDistCard {
    protected HwTextView ʻ;
    protected HwButton ʼ;
    protected TextView ʽ;
    protected View ˊॱ;
    protected ImageView ˋ;
    protected ProductDetailBean ͺ;
    protected ehw ॱˊ;
    protected TextView ॱॱ;
    protected TextView ᐝ;

    public class d implements crj {
        final /* synthetic */ ProductListCard ॱ;

        public d(ProductListCard productListCard) {
            this.ॱ = productListCard;
        }

        public void ˎ(int i, ProductDetailBean productDetailBean) {
            if (this.ॱ.ˊᐝ instanceof ehw) {
                ehw o_ehw = (ehw) this.ॱ.ˊᐝ;
                switch (i) {
                    case 0:
                        if (((ehw) this.ॱ.ˊᐝ).ॱꜟ() == 1) {
                            o_ehw.ˏॱ(2);
                            this.ॱ.ʼ.setEnabled(false);
                            this.ॱ.ʼ.setText(this.ॱ.ʼॱ.getResources().getString(n.ʼꜞ));
                            Toast.makeText(this.ॱ.ʼॱ, n.ʼꓸ, 0).show();
                            return;
                        }
                        return;
                    case 4:
                        o_ehw.ʽ(0);
                        this.ॱ.ˎ();
                        return;
                    case 5:
                        Toast.makeText(this.ॱ.ʼॱ, n.ʼꞌ, 0).show();
                        return;
                    case 6:
                        o_ehw.ˏॱ(2);
                        this.ॱ.ʼ.setEnabled(false);
                        this.ॱ.ʼ.setText(this.ॱ.ʼॱ.getResources().getString(n.ʼꜞ));
                        Toast.makeText(this.ॱ.ʼॱ, n.ʼꜞ, 0).show();
                        return;
                    default:
                        Logger.ˎ("ProductListCard", "Purchase failure");
                        return;
                }
            }
        }
    }

    public ProductListCard(Context context) {
        super(context);
    }

    public cgz ˏ(View view) {
        ʽ(view);
        ˎ(view);
        this.ˋ = (ImageView) view.findViewById(j.ʻˊ);
        this.ʽ = (TextView) view.findViewById(j.ᵔˊ);
        this.ᐝ = (TextView) view.findViewById(j.ᵕॱ);
        this.ॱॱ = (TextView) view.findViewById(j.ᵔᐝ);
        this.ʼ = (HwButton) view.findViewById(j.ᵣॱ);
        this.ʻ = (HwTextView) view.findViewById(j.ᵢˏ);
        this.ˊॱ = view.findViewById(j.ᐧᐝ);
        return this;
    }

    protected void ˎ(View view) {
        azb.ˏ(view);
    }

    public void ˏ(CardBean cardBean) {
        if (cardBean instanceof ehw) {
            this.ˊᐝ = cardBean;
            this.ॱˊ = (ehw) cardBean;
            eqx.ˏ(this.ˋ, this.ॱˊ.ʼˊ(), "image_default_icon");
            ˊ(this.ʽ, this.ॱˊ.ʻˋ());
            ˊ(this.ᐝ, this.ॱˊ.ʻˊ());
            ˏ(this.ॱˊ);
            ˋ(this.ॱˊ);
            if (ˊᐝ()) {
                this.ˊॱ.setVisibility(0);
            } else {
                this.ˊॱ.setVisibility(4);
            }
        }
    }

    private void ˋ(ehw o_ehw) {
        this.ͺ = new ProductDetailBean();
        this.ͺ.ʾ(o_ehw.ʼˊ());
        this.ͺ.ॱʼ(o_ehw.ʻˋ());
        this.ͺ.ॱʻ(o_ehw.ʻˊ());
        this.ͺ.ˈ(o_ehw.ʻᐝ());
        this.ͺ.ʼॱ(o_ehw.ʼˋ());
        this.ͺ.ˎˏ(o_ehw.ʼᐝ());
        this.ͺ.ˑ(o_ehw.ʽˊ());
        this.ͺ.ˎ(o_ehw.ʾॱ());
        this.ͺ.ͺॱ(o_ehw.ʽˋ());
        this.ͺ.ـ(o_ehw.ʽᐝ());
        this.ͺ.ॱʽ(o_ehw.ॱﾞ());
        this.ͺ.ᐝ(o_ehw.ʿॱ());
        this.ͺ.ʽ(o_ehw.ˊʻ());
        this.ͺ.ʼ(o_ehw.ॱꞌ());
        this.ͺ.ˏॱ(o_ehw.ॱꜟ());
        this.ͺ.ʻ(o_ehw.ˌ());
        this.ͺ.ˉ(o_ehw.ͺˏ());
        this.ͺ.ˊˊ(o_ehw.י());
    }

    private void ˏ(ehw o_ehw) {
        this.ʼ.setEnabled(o_ehw.ˌ() == 0);
        if (o_ehw.ॱꜟ() == 1) {
            ॱ(o_ehw, true);
        } else if (o_ehw.ॱꜟ() == 2) {
            this.ʼ.setText(this.ʼॱ.getResources().getString(n.ʼꜞ));
            this.ʼ.setEnabled(false);
            ˋ(o_ehw.ʼᐝ(), o_ehw.ʻᐝ());
            this.ॱॱ.setVisibility(8);
        } else {
            ॱ(o_ehw, false);
        }
    }

    private void ˊ(TextView textView, String str) {
        if (dof.ˋ(str)) {
            textView.setVisibility(8);
            return;
        }
        textView.setVisibility(0);
        textView.setText(str);
    }

    private void ॱ(ehw o_ehw, boolean z) {
        if (o_ehw.ॱꞌ() <= 0 && o_ehw.ॱꞌ() != -1) {
            this.ʼ.setEnabled(false);
            this.ʼ.setText(this.ʼॱ.getResources().getString(n.ʼᶥ));
            this.ʻ.setVisibility(8);
            this.ॱॱ.setVisibility(8);
        } else if (z) {
            ˊ(o_ehw);
        } else {
            ˎ(o_ehw);
        }
    }

    protected void ˋ(String str, String str2) {
        CharSequence ॱ = ॱ(str, str2);
        if (dof.ˋ(ॱ)) {
            this.ʻ.setVisibility(8);
            return;
        }
        this.ʻ.setVisibility(0);
        CharSequence spannableString = new SpannableString(ॱ);
        spannableString.setSpan(chm.ॱ, 0, spannableString.length(), 33);
        this.ʻ.setText(spannableString);
    }

    private String ॱ(String str, String str2) {
        String str3 = null;
        try {
            if (Float.valueOf(str2).floatValue() > 0.0f) {
                str3 = eed.ˋ(str, str2);
            }
        } catch (Exception e) {
            Logger.ˋ("ProductListCard", "getPriceContent error");
        }
        return str3;
    }

    private void ˊ(ehw o_ehw) {
        long ʾॱ;
        int i;
        if (o_ehw.ʾॱ() > 0) {
            ʾॱ = o_ehw.ʾॱ() - System.currentTimeMillis();
            if (ʾॱ <= 0) {
                Object obj = null;
            } else {
                i = 1;
            }
        } else {
            ʾॱ = 0;
            i = 1;
        }
        if (obj != null) {
            this.ʼ.setText(this.ʼॱ.getResources().getString(n.ʼꜟ));
            ˋ(o_ehw.ʼᐝ(), o_ehw.ʻᐝ());
            ˎ(o_ehw.ʾॱ(), ʾॱ);
            return;
        }
        ˎ(o_ehw.ʼᐝ(), o_ehw.ʻᐝ());
        this.ʻ.setVisibility(8);
        this.ॱॱ.setVisibility(8);
    }

    private void ˎ(ehw o_ehw) {
        if (dof.ˋ(o_ehw.ʼˋ())) {
            ˎ(o_ehw.ʼᐝ(), o_ehw.ʻᐝ());
            this.ʻ.setVisibility(8);
            this.ॱॱ.setVisibility(8);
        } else if (o_ehw.ʾॱ() > 0) {
            long ʾॱ = o_ehw.ʾॱ() - System.currentTimeMillis();
            if (ʾॱ > 0) {
                ˎ(o_ehw.ʼᐝ(), o_ehw.ʼˋ());
                ˋ(o_ehw.ʼᐝ(), o_ehw.ʻᐝ());
                ˎ(o_ehw.ʾॱ(), ʾॱ);
                return;
            }
            ˎ(o_ehw.ʼᐝ(), o_ehw.ʻᐝ());
            this.ʻ.setVisibility(8);
            this.ॱॱ.setVisibility(8);
        } else {
            ˎ(o_ehw.ʼᐝ(), o_ehw.ʼˋ());
            ˋ(o_ehw.ʼᐝ(), o_ehw.ʻᐝ());
            this.ॱॱ.setVisibility(8);
        }
    }

    protected void ˎ(String str, String str2) {
        CharSequence ॱ = ॱ(str, str2);
        if (dof.ˋ(ॱ)) {
            this.ʼ.setVisibility(8);
            return;
        }
        this.ʼ.setVisibility(0);
        this.ʼ.setText(ॱ);
    }

    private void ˎ(long j, long j2) {
        if (j2 > 0) {
            this.ॱॱ.setVisibility(0);
            if (dof.ˋ(eed.ˋ(this.ʼॱ, j, System.currentTimeMillis()))) {
                this.ॱॱ.setVisibility(8);
                return;
            }
            this.ॱॱ.setText(this.ʼॱ.getResources().getString(n.ˋʽ, new Object[]{r0}));
            return;
        }
        this.ॱॱ.setVisibility(8);
    }

    public void ॱ(chy o_chy) {
        this.ʼ.setOnClickListener(new evx(this) {
            final /* synthetic */ ProductListCard ॱ;

            {
                this.ॱ = r1;
            }

            public void ˋ(View view) {
                if (this.ॱ.ʼॱ instanceof Activity) {
                    eec.ˊ().ˎ((Activity) this.ॱ.ʼॱ, this.ॱ.ͺ, new d(this.ॱ));
                }
            }
        });
    }

    private void ˎ() {
        cku ˏ = cku.ˏ(this.ʼॱ, cku.class, null, this.ʼॱ.getResources().getString(n.ʼᐨ));
        ˏ.ॱ(-1, this.ʼॱ.getResources().getString(n.ʼـ));
        ˏ.ˎ(-2, 8);
        ˏ.ॱ(new cks(this) {
            final /* synthetic */ ProductListCard ˊ;

            {
                this.ˊ = r1;
            }

            public void enableNetworking() {
                this.ˊ.ʼ.setText(ContentManager.getInstant().getContext().getResources().getString(n.ʼᶥ));
                this.ˊ.ʼ.setEnabled(false);
            }

            public void upgrade() {
            }

            public void ˋ() {
            }
        });
        ˏ.ˋ(this.ʼॱ, this.ͺ.ॱ());
    }
}
